<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="../inc/inc.jsp" flush="true"></jsp:include>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/kindeditor/themes/default/default.css" />
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/kindeditor/plugins/code/prettify.css" />
    <script type="text/javascript" src="<%=request.getContextPath() %>/static/kindeditor/kindeditor.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/static/kindeditor/lang/zh_CN.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/static/kindeditor/plugins/code/prettify.js"></script>

    <script type="text/javascript">
        var self;
        KindEditor.ready(function(K) {
            var editor = K.create('#content', {
                cssPath : '${pageContext.request.contextPath}/static/kindeditor/plugins/code/prettify.css',
                uploadJson : '${pageContext.request.contextPath}/info/fileupload',
                fileManagerJson : '${pageContext.request.contextPath}/info/filemanager',
                allowFileManager : true,
                resizeType:0,    //2或1或0，2时可以拖动改变宽度和高度，1时只能改变高度，0时不能拖动
                afterCreate : function() {
                    self = this;
                }
            });
            // 			prettyPrint();
        });


        function saveNews(){
            self.sync();  // 同步数据后可以直接取得textarea的value--------------增加这个controller才能获取到
            var content = $("#content").val();
            var data = form2Json("fm");
            if($("#fm").form('validate')){
                $.post('${pageContext.request.contextPath}/news_save',{data:data,content:content},function(result) {
                    result = $.parseJSON(result);
                    if(result.success){
                        parent.reloadTabGrid("新闻管理","新闻编辑");
                    }else{
                        $.messager.show({
                            title: '提示',
                            msg: result.msg
                        });
                    }
                });
            }
        }

    </script>
</head>

<body>
    <form id="fm" method="post" enctype="multipart/form-data">
        <table class="grid">
            <input type="hidden" name="id" value="${news.id }"/>
            <input type="hidden" name="contentId" value="${news.contentId }"/>
            <tr>
                <td>标题</td>
                <td style="width: 880px" colspan="3"><input name="title" style="width: 600px" class="easyui-textbox" data-options="required:true,validType:'maxLength[64]'" value="${news.title }"></td>
                <td>时间</td>
                <td><input name="time" class="easyui-datebox" data-options="editable:false" value="${news.time }" /></td>
            </tr>
            <tr>
                <td>副标题</td>
                <td><input name="subTitle" style="width: 500px" class="easyui-textbox" data-options="validType:'maxLength[64]'" value="${news.subTitle }"></td>
                <td style="width: 60px">作者</td>
                <td><input name="writer"  class="easyui-textbox" data-options="" value="${news.writer }"></td>
                <td colspan="2">摘要</td>
            </tr>

            <tr height="220px">
                <td colspan="4" rowspan="2">
                    <textarea id="content" style="width:100%;height:390px">${content }</textarea>
                </td>
                <td colspan="2"><input type="text" name="digest" class="easyui-textbox" data-options="width:200,multiline:true,height:380,validType:'maxLength[64]'" value="${news.digest }"/></td>
            </tr>
            <tr>
                <td>排序</td>
                <td><input name="orderNo" class="easyui-numberspinner"  data-options="min:0,max:1000" value="${news.orderNo }"> </td>
            </tr>

        </table>
    </form>
    <div style="text-align:center;padding-top:8px;">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="javascript:saveNews();" style="width:90px;">保存</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:closeTabs();" style="width:90px;">关闭</a>
    </div>
</body>
</html>




